<{include file="app/header.tpl"}>

<form action="/m/order/create/toFriends" class="order-wrap" method="POST">

    <ul id="buy-goods">
        <{foreach from=$goodsList item="goods"}>
            <li class="order-goods">

                <div class="left"><img class="img" src="<{$goods.thumbsrc}>" align="absmiddle" alt=""></div>
                <div class="middle">

                        <p class="title"><{$goods.name}></p>

                        <p class="prompt"><{if $goods.attr.desc}><{$goods.attr.desc}><{/if}></p>

                        <p class="number">数量：<{$goods.money.quantity}></p>
                </div>
                <div class="bottom">
                    <p id="goods-buy-money">￥<{$goods.money.money/100|@number_format:2}></p>
                </div>
                <input type="hidden" name="goodsId[]" value="<{$goods.id}>">
                <input type="hidden" name="goodsAttrId[]" value="<{$goods.attr.id}>">
                <input type="hidden" name="goodsPrice[]" value="<{$goods.money.price}>">
                <input type="hidden" name="goodsQuantity[]" value="<{$goods.money.quantity}>">

            </li>
        <{/foreach}>
    </ul>


    <div class="order-pay" id="buy-payment">
        <h2 class="pay">支付方式</h2>
        <{foreach from=$payment item="p"}>
        <h3 class="payInfo">
            <label><input type="radio" name="paymentId" value="<{$p.id}>" class="radio" <{if $payment|@count == 1}>checked="checked"<{/if}>><span class="wechat"></span></label>
            <em class="downIcon" id="buy-payment-icon"></em>
        </h3>
        <{/foreach}>
    </div>

    <div id="buy-tickets">
       <div class="order-coupon">
            <input type="text" name="comments" class="order-user-notes" placeholder="礼物留言">
        </div>
    </div>

    <div id="buy-deliver">
        <div class="order-kuaidi">
            <h3 class="manner">快递方式</h3>
            <ul class="user-kuaidi">
            <{foreach from=$deliver item="p"}>
                <li>
                <label>
                    <input class="radio" type="radio" name="deliverId" value="<{$p.id}>" money="<{$p.goodsDeliverMoney}>">
                    <span class="kuaidi-prompt"> <{$p.name}>
                        (默认运费: ￥<{$p.ltMoneyFee/100|number_format:2}>
                        /
                        购买超过<{$p.money/100|number_format:2}>元商品运费￥<{$p.egtMoneyFee/100|number_format:2}>)
                    </span>
                </label>
                </li>
            <{/foreach}>
            </ul>
        </div>
    </div>

    <div class="order-fee-details">
        <h2 class="detail"><span class="rmb">￥</span>费用详情</h2>
        <p class="line fix"><span class="left">商品金额：</span><span class="right">￥<{$money.goods/100|@number_format:2}></span></p>
        <p class="line fix"><span class="left">快递</span><span class="right deliverMoney">￥+0.00</span></p>
       <input type="submit" class="submitBtn" onclick="return submit_buy_now();" name="submit_op" value="支付礼物">
    </div>

</form>

<script>

    function submit_buy_now() {

        var oRadioVal = $('input:radio[name="deliverId"]:checked').val();
        if (! oRadioVal) {
            alert('请选择快递方式');
            return false;
        }

        return true;
    }

    function deliver_config_changed (item)
    {
        var money = parseInt($(item).attr('money')) / 100;
        $('.deliverMoney').html('￥+' + money);
    }

    $(document).ready(function () {

        // 快递动作响应
        $('input[name="deliverId"]').click(function () {
            deliver_config_changed(this);
        });
        var dItem = $('input[name="deliverId"]').get(0);
        $(dItem).attr('checked', 'checked');
        deliver_config_changed(dItem);

        // 支付选择
        $('#buy-payment-icon').click(function() {
            if ($(this).hasClass('downIcon'))
                $(this).removeClass('downIcon').addClass('upIcon');
            else
                $(this).removeClass('upIcon').addClass('downIcon');
        });

    });

</script>

<{include file="app/footer.tpl"}>
